<style>
.fui-goods-item .image {
    height: 7rem;
    width: 11rem;
}
.fui-goods-group {
    padding:0.3rem
}
.timer {
    font-size: .6rem;
    height: .95rem;
    color: #ef4f4f;
}
.timer span {
    display: inline-block;
    background:#582e19;
    color:#fff;
    width:.9rem;height:.9rem;
    border-radius: .1rem;
    line-height:.9rem;
    font-size:.5rem; text-align: center;
}
.fee-tag-zi {background:#de3025;color:#fff;width:auto;font-weight:400;font-size:0.6rem}
.jylabel-red.active, .jylabel-red:focus, .jylabel-red:hover, .jylabel-red[href]:focus, .jylabel-red[href]:hover {
    background-color: red;
    color: #fff;
    border: 1px solid red;
}
.fui-cell-group .fui-cell .fui-cell-label {
    font-size: 0.75rem;
    color: #333;
}
.fui-number .minus:before, .fui-number .plus:before {
	border-left: 0 solid #d9d9d9;
}
.fui-number .minus:after, .fui-number .plus:after {
	border-right: 0 solid #d9d9d9;
}
.fui-number:before {
	border-top: 0 solid #d9d9d9;
}
.fui-number:after {border-top: 0 solid #d9d9d9;}
.fui-number .num {
	color:#666;
}
.fui-number .num {
	color:#666;
}
.fui-number.small {
	height: 1.2rem;
	width: auto;
	line-height: 1.2rem;
}
.fui-number .minus, .fui-number .plus {
	z-index:0;
}
.fui-number.small .minus{
	color: {{main.syscolor || '#63BE72'}};
	padding-top:1px;
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
 .fui-number.small .plus {
	color: #fff;
	padding-top:1px;
	background: {{main.syscolor || '#63BE72'}};
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
</style>
	<div ng-if="!pagedata.loading && pagedata.list.length>0" class="fui-goods-group no" style="background-color:#fff">
			<div ng-repeat="item in pagedata.list" class="fui-goods-item" style="padding:0;margin:0.3rem 0.1rem;border: 0px solid #e7e7e7;">
				<div ng-click="pagedata.gotoitem(item);" ng-if="!item.video || pagedata.shopset.no_video==1" ng-class="{'image':1, 'echelon':item.active.title}" data-text="{{item.active.title}}" style="background-image: url({{tomedia(item.image) ||'../core/resource/images/nopic.jpg'}})">
				</div>
				<div ng-if="item.video && pagedata.shopset.no_video !=1" class="image">
					<video style="width:100%;height:100%;background:#999" controls="" x5-playsinline="" playsinline="" webkit-playsinline="" preload="auto"
						  poster="{{tomedia(item.image) || '../core/resource/images/nopic.jpg'}}"
						  data-setup='{"controls": true, "autoplay": false}'>
						  <source ng-src="{{tomedia(item.video)}}" type="video/mp4">					 
					</video>
				</div>
				<div class="detail" style="height:2.6rem;padding-left:0.3rem;padding-top:0.2rem">
					<div ng-click="pagedata.gotoitem(item);" class="overflow-h" style="width:9rem">
						<div class="fui-tag fui-tag-danger fee-tag-zi" style="margin-right:0.15rem">{{pagedata.pluginset.saletag ||'年货节'}}</div>	{{item.title}}
					</div>
					<div ng-if="item.active.rest_time" class="timer" ng-init="tool.time_down(pagedata.list[$index].active.rest_time)" style="margin-top: 0.2rem;width:10rem">
							{{item.active.status==0?'距开始':'距结束'}}  <span class="time-day">{{pagedata.list[$index].active.rest_time.day}}天</span>:<span class="time-hour">{{pagedata.list[$index].active.rest_time.hour}}</span>:<span class="time-min">{{pagedata.list[$index].active.rest_time.minute}}</span>:<span class="time-sec">{{pagedata.list[$index].active.rest_time.second}}</span>
					</div>
					<div ng-if="!item.active.rest_time" class="fui-tag fui-tag-danger" style="margin-top: 0.2rem;background:linear-gradient(to right,rgba(244,221,187,0.6),rgba(235,216,174,1));color:#512f0a;width:auto;font-weight:400">近7日热卖排行榜第{{$index}}位</div>
					<div class="title" style="margin-top: 0.2rem;bottom:0.1rem;">
						<span class="red">直降￥{{item.jianprice || '0.00'}}</span> <span class="gray"> 限量热卖</span>
					</div>
					<div class="title" style="margin-top: 0.2rem;bottom:0.1rem;">
						<span class=" fui-buys-info" style="width:6rem;padding-right:0.6rem">
								<img ng-repeat="m in item.members" ng-if="$index<3" class="avatar" style="width:1.3rem;height:1.3rem;margin-right:-0.6rem" ng-src="{{tomedia(m.avatar) || '../core/resource/images/nopic.jpg'}}">
						</span>
						<span class="text"><span class="subtitle" style="font-weight:400;padding-left:0.2rem">已售{{item.salenum || 0}}{{item.unit || '件'}}</span></span>
					</div>
					<div class="title">
						<span class="red" style="margin-top:0.1rem;line-height:1.8">￥ 
							<span ng-if="!item.active.price" style="font-weight:bold;font-size:1rem;">{{item.price}}</span>
							<span ng-if="item.active.price" style="font-weight:bold;font-size:1rem;">{{item.active.price}}</span>
						</span>
						<span ng-if="item.total<=0" class="jylabel jylabel-f3f3f3 r-f" style="padding:0 0.3rem;border-radius:0.3rem;font-weight:400;border-radius:1rem">已售罄</span>
						<span ng-if="item.carttotal==0 && item.total>0" href="javascript:" ng-click="pagedata.plus($index)" class="jylabel jylabel-red active r-f" style="padding:0 0.3rem;border-radius:0.3rem;font-weight:400;border-radius:1rem">加入购物车</span>
						<span ng-if="(!item.specs_list || item.specs_list.length < 1) && item.carttotal>0" class="fui-number small r-f" style="right:0;margin-top:0.3rem">
							<span class="minus" ng-click="pagedata.minus($index)"><i class="icon icon-subtract" style="font-size:0.7rem"></i></span>
								<input ng-if="item.carttotal>0" class="num shownum" type="text" ng-model="item.carttotal" style="width:1rem" ng-change="pagedata.refresh()"/>
							<span class="plus" ng-click="pagedata.plus($index)"><i class="icon icon-tianjia" style="font-size:0.7rem"></i></span>
						</span>
					</div>
				</div>
			</div>
	</div>
<div ng-show="pagedata.loading" class='infinite-loading'><span class='fui-preloader'></span><span style="margin-left:1.5rem"> 正在加载...</span></div>
<script>
scope.pagedata.params=scope.pagedata.params?scope.pagedata.params:{};
var pcate=scope.pagedata.params.pid?scope.pagedata.params.pid:'';
var order=scope.pagedata.params.order?scope.pagedata.params.order:'ishot';
scope.tool.get_list('jy_duotuan/goods.index/getlist/order='+order+'&pcate='+pcate,true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_duotuan/goods.index/getlist/');
}
scope.pagedata.gotoitem=function(item){
	scope.access_json(item.active.url || 'jy_duotuan/goods.detail//id='+item.id);
}
//刷新总数和总价
scope.pagedata.refresh=function(){
	var cartnums=0;
	var totalprice=0
	angular.forEach(scope.pagedata.carts,function(cart){
		cartnums+=parseInt(cart.total);
		totalprice+=cart.total*cart.price;
	});
	scope.pagedata.cartnums=cartnums;
	console.log(scope.pagedata.cartnums);
	scope.pagedata.totalprice=totalprice;
	scope.pagedata.showprice=scope.price(scope.pagedata.totalprice);
	scope.$evalAsync();
}
//减少
scope.pagedata.minus=function(index){
	var g = scope.pagedata.list[index]
	if(g.carttotal<=0){
		return false;
	}
	scope.post_json('jy_duotuan/member.cart/minus/selected=1',{'getlist':true,'id':g.cartid},function(res){
			g.carttotal--;
			scope.pagedata.list[index]=g
			scope.pagedata.carts=res.list
			scope.pagedata.refresh();
	});
}
//增加
scope.pagedata.plus=function(index){
	var g = scope.pagedata.list[index]
	g.optionid=0;
	if(g.carttotal>=g.total){
			scope.message('不能再添加了，已超过库存！','error');
			return false;
	}
	scope.post_json('jy_duotuan/member.cart/addtocart/selected=1',{'getlist':true,'goodsid':g.id,'optionid':g.optionid},function(res){
			console.log(res);
			g.carttotal++;
			if(res!='success'){
				g.cartid=res.id;
				scope.pagedata.carts=res.list
			}
			scope.pagedata.list[index]=g
			scope.pagedata.refresh();
	});
}
//减少
scope.pagedata.sp_minus=function(){
	var g =scope.pagedata.g;
	if(g.carttotal<=0){
		return false;
	}
	scope.post_json('jy_duotuan/member.cart/minus/selected=1',{'getlist':true,'id':g.cartid,'optionid':g.options.id},function(res){
			g.carttotal--;
			if(g.post[g.options.id].num<=0){
				return false;
			}
			scope.pagedata.carts=res.list
			g.post[g.options.id].num--;
			scope.pagedata.list[scope.pagedata.nowgkey]=g
			scope.pagedata.refresh();
			
	});
}
//增加
scope.pagedata.sp_plus=function(){
	var g =scope.pagedata.g;
	if(g.carttotal>=g.options.stock){
		scope.message('不能再添加了，已超过库存！','error');
		return false;
	}
	scope.post_json('jy_duotuan/member.cart/addtocart/selected=1',{'getlist':true,'goodsid':g.id,'optionid':g.options.id},function(res){
			g.carttotal++;
			g.post[g.options.id].num++;
			if(res!='success'){
				g.cartid=res.id;
			}
			scope.pagedata.list[scope.pagedata.nowgkey]=g
			scope.pagedata.refresh();
	});
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.g.specid;
	specid = specid.join('_');
	scope.post_json('jy_weishop/goods.detail/get_optionsid/',{'goodsid':scope.pagedata.g.id,'specid':specid},function(res){
			var optionsid=res.options.id;
			scope.pagedata.g.options=res.options;
			scope.pagedata.g.selespename=res.selespename;
			if(!scope.pagedata.g.post[optionsid]){
				scope.pagedata.g.post[optionsid]={}
				scope.pagedata.g.post[optionsid]={
					'num':scope.pagedata.g.post[optionsid].num?scope.pagedata.g.post[optionsid].num:res.carttotal,
					'title':res.selespename,
				}
			}
			
			scope.$evalAsync();
	});
}
</script>
